<?php

namespace app\models;

use app\components\BaseActiveRecord;
use Yii;

/**
 * This is the model class for table "{{%post_meta}}".
 *
 * @property int $id
 * @property int $type
 * @property int $post_id
 * @property string $name
 */
class PostMeta extends BaseActiveRecord {

    const TYPE_ATTACHMENT = 1;
    const TYPE_VIDEO_URL = 2;
    const TYPE_TAG = 3;
    const TYPE_DOWNLOAD = 4;


    /**
     * @inheritdoc
     */
    public static function tableName() {
        return '{{%post_meta}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['type', 'post_id'], 'integer'],
            [['name'], 'string', 'max' => 200],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'type' => 'Type',
            'post_id' => 'Post ID',
            'name' => 'name',
        ];
    }

    public function getPost() {
        return $this->hasOne(Post::class, ['id' => 'post_id']);
    }
}
